  //
//  MainPlayerViewController.m
//  SuperRadio
//
//  Created by Damon on 14/12/17.
//  Copyright (c) 2014年 三个臭皮匠. All rights reserved.
//

#import "MainPlayerViewController.h"
#import "HotSoundDetailsViewController.h"
#import "NetHandler.h"
#import "UIImageView+WebCache.h"
#import "AlbumDatailsOfList.h"
#import "Host.h"
#import "PlayerView.h"
#import "HostAttentionCell.h"
#import "HostAttentionDetail.h"
#import "HostViewController.h"
#import "Introduction.h"

#import "JingRoundView.h"

#import "AudioPlayer.h"
#import "AudioButton.h"
// 分享头文件
#import "AppDelegate.h"
#import "WeiboSDK.h"
#import "DataBaseHandler.h"

#define kRedirectURI @"http://www.sina.com"

@interface MainPlayerViewController ()<UITableViewDataSource, UITableViewDelegate>

// 表视图
@property(nonatomic, retain)UITableView *playTableView;
// 专辑中de音频数组
@property(nonatomic, retain) NSMutableArray *soundsArr;

@property(nonatomic, retain) UILabel *labelID;

@property(nonatomic, retain) UIImageView *playImageView;

@property(nonatomic, retain) UILabel *labelTitle;

@property (nonatomic, retain) NSMutableArray *imageArr;

@property (nonatomic, retain) Host *host;

@property (nonatomic, retain) UITableView *tableView;

@property (nonatomic, retain) UIView *headerView;

@property (nonatomic, retain) HostAttentionDetail *hostAttention;
// 播放模式
@property (nonatomic, assign) NSInteger playModel;
// 是否收藏成功
//@property (nonatomic, assign) BOOL successCollect;

@end

@implementation MainPlayerViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.imageArr = [NSMutableArray array];
        self.soundsArr = [NSMutableArray array];
        self.hostAttention = [[HostAttentionDetail alloc] init];
        self.listArr = [NSMutableArray array];
        self.playModel = 0;
        
//        // 注册收藏按钮的通知中心
//        NSNotificationCenter *collectFicationT = [NSNotificationCenter defaultCenter];
//        // 增加一个观察者
//        [collectFicationT addObserver:self selector:@selector(collectFicationT:) name:@"collect" object:nil];
//        // 初始化 让是否收藏成功为no
//        self.successCollect = NO;
        
        DataBaseHandler *handler = [DataBaseHandler shareInstance];
        // 打开数据库
        [handler openDB];
        // 创建用户表
        [handler createCollectTable];
    }
    
    return self;
}

- (void)viewWillAppear:(BOOL)animated
{
    // view将要出现 隐藏navigationBar.hidden
    [super viewWillAppear:animated];
    self.navigationItem.backBarButtonItem = NO;
    self.navigationController.navigationBar.hidden = YES;
     self.tabBarController.tabBar.hidden = YES;
}



- (void)viewWillDisappear:(BOOL)animated
{
    // view将要消失 不隐藏navigationBar.hidden
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = NO;
    self.tabBarController.tabBar.hidden = NO;
    
}

+ (MainPlayerViewController *)defaultPlayer
{
     static MainPlayerViewController *mainPlayerVC = nil;
    
    if (mainPlayerVC == nil) {
        mainPlayerVC = [[MainPlayerViewController alloc] init];
    }
    
    return mainPlayerVC;
}

#pragma mark 获得专辑列表
- (void)getAlbumList
{
    NSString *path = [NSString stringWithFormat:@"http://mobile.ximalaya.com/mobile/playlist/album?albumId=%@&device=iPhone&trackId=%@", self.albumDatail.albumId,self.trackId];
    
    [self.soundsArr removeAllObjects];
    
    [NetHandler getDataWithURL:path completion:^(NSData *data) {
        
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        
        NSArray *arr = [dic objectForKey:@"data"];
        
        for (NSDictionary *dic in arr) {
            
            AlbumDatailsOfList *detail = [[AlbumDatailsOfList alloc] initWithDictionary:dic];
            
            [self.soundsArr addObject:detail];
            [detail release];
            
        }
 
    }];
    
}



#pragma mark 相关专辑的数据解析
- (void)getInfor
{
    NSString *path = [NSString stringWithFormat:@"http://mobile.ximalaya.com/mobile/track/detail?device=iPhone&trackId=%@", [self.trackId stringValue]];
    
    [NetHandler getDataWithURL:path completion:^(NSData *data) {
        
        NSDictionary *result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        
        _hostAttention = [[HostAttentionDetail alloc] initWithDictionary:[result objectForKey:@"userInfo"]];
        
        _host = [[Host alloc] initWithDictionary:[result objectForKey:@"userInfo"]];
       _albumDatail = [[AlbumDatailsOfList alloc] initWithDictionary:result];
        
        [self.imageArr removeAllObjects];
        [self.imageArr addObjectsFromArray:[result objectForKey:@"images"]];
        // 给音频的标题赋值
        _labelTitle.text = self.albumDatail.title;
        // 给音频的图片赋值
        
        if (self.imageArr.count != 0) {
            
            [self.playImageView setImageWithURL:[NSURL URLWithString:[self.imageArr objectAtIndex:0]]];
            _audioPlayer.imagePath = [self.imageArr objectAtIndex:0];
        }else {
            
            
            self.playImageView.image = [UIImage imageNamed:@"listen.jpg"];

        }
        
        
        // tableView重新加载数据
        [self.tableView reloadData];
        
    }];
}

#pragma mark 点击cell
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    HostViewController *hostVC = [[HostViewController alloc] init];
    
    hostVC.introduction.uid = self.host.uid;
    self.tabBarController.tabBar.hidden = NO;
    [self.navigationController popViewControllerAnimated:NO];

    // 推出播主页面
    [self.navi pushViewController:hostVC animated:YES];
    self.navi.navigationBar.hidden = NO;
    

    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
    
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return [NSString stringWithFormat:@"section:%ld", section];
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    HostAttentionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reUse"];
    

    
    cell.hostAttention = self.hostAttention;
    
    
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 130;
}

// 设置section的header
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
    if (sectionTitle == nil) {
        return nil;
    }
    
    // 创建一个sectionView
    UIView *sectionView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, tableView.bounds.size.height)] autorelease];
    [sectionView setBackgroundColor:[UIColor clearColor]];
    // sectionView.userInteractionEnabled = YES;
    // 将播放的View添加到sectionView上
   [sectionView addSubview:self.playerView];
    
    return sectionView;
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.playerView = [[PlayerView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 140)];
    
    
    // 上一首按钮
    NSString *upPath = [[NSBundle mainBundle] pathForResource:@"shangyishou2" ofType:@"png"];
    // 在上一首的按钮上添加图片
    [self.playerView.upButton setImage:[UIImage imageWithContentsOfFile:upPath] forState:UIControlStateNormal];
    // 上一首按钮的方法
    [self.playerView.upButton addTarget:self action:@selector(PlayUpSound:) forControlEvents:UIControlEventTouchUpInside];
    
    // 下一首按钮
    NSString *nextPath = [[NSBundle mainBundle] pathForResource:@"xiayishou2" ofType:@"png"];
    // 在下一首按钮上添加图片
    [self.playerView.nextButton setImage:[UIImage imageWithContentsOfFile:nextPath] forState:UIControlStateNormal];
    
    // 下一首按钮的方法
    [self.playerView.nextButton addTarget:self action:@selector(PlayNextSound:) forControlEvents:UIControlEventTouchUpInside];
    
    NSString *circlePath = [[NSBundle mainBundle] pathForResource:@"ttpodicon-1" ofType:@"png"];
    [self.playerView.playModelButton setImage:[UIImage imageWithContentsOfFile:circlePath] forState:UIControlStateNormal];
    [self.playerView.playModelButton addTarget:self action:@selector(playModelClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    
    // 列表按钮的图片添加
    
    // 收藏按钮
   ///UIButton *collect = [UIButton buttonWithType:UIButtonTypeSystem];
   // collect.frame = CGRectMake(self.view.frame.size.width / 5 * 4 + 45, 35, 20, 20);
    // 给收藏按钮添加图片
   /// NSString *collPath = [[NSBundle mainBundle] pathForResource:@"shoucang" ofType:@"png"];
    //[collect setImage:[UIImage imageWithContentsOfFile:collPath] forState:UIControlStateNormal];
    // 给收藏按钮添加点击事件
    //[collect addTarget:self action:@selector(CollectClicked:) forControlEvents:UIControlEventTouchUpInside];
   // [view addSubview:collect];
    
    NSString *listPath = [[NSBundle mainBundle] pathForResource:@"shoucang" ofType:@"png"];
    
    [self.playerView.shareButton setImage:[UIImage imageWithContentsOfFile:listPath] forState:UIControlStateNormal];
    [self.playerView.shareButton addTarget:self action:@selector(CollectClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    // 设置标题的view 设置frame为导航栏的frame
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 64)];
    view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view];
    
    // tableView的设置
    // 设置tableView的x为View的y+height
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, view.frame.origin.y + view.frame.size.height, self.view.bounds.size.width, self.view.bounds.size.height - 64) style:UITableViewStyleGrouped];
    // 签订代理
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    // 将sectionHeader的高设置为View的宽
    self.tableView.sectionHeaderHeight = self.view.bounds.size.width;
    self.tableView.showsVerticalScrollIndicator = NO;
    // 注册一个系统cell
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuse"];
    // 注册一个HostAttentionCell类的cell
    [self.tableView registerClass:[HostAttentionCell class] forCellReuseIdentifier:@"reUse"];
    [self.view addSubview:self.tableView];
    
    
    
    // 返回按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(10, 30, 64 - 40, 64 - 40);
    // 返回按钮添加图片
    NSString *path = [[NSBundle mainBundle] pathForResource:@"fanhui" ofType:@"png"];
    [button setImage:[UIImage imageWithContentsOfFile:path] forState:UIControlStateNormal];
    // 给返回按钮添加方法
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:button];
    
    
    // 分享按钮
    UIButton *share = [UIButton buttonWithType:UIButtonTypeSystem];
    share.frame = CGRectMake(self.view.frame.size.width - 34, 32, 24, 24);
    // 给分享按钮添加图片
    NSString *sharePath = [[NSBundle mainBundle] pathForResource:@"share1" ofType:@"png"];
    [share setImage:[UIImage imageWithContentsOfFile:sharePath] forState:UIControlStateNormal];
    // 给分享按钮添加点击事件
    [share addTarget:self action:@selector(ShareClicked:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:share];
    
    
   
    
    
    
    
    // 音频标题
    self.labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(35, 30, self.view.bounds.size.width - 34 - 35, 24)];
    self.labelTitle.font = [UIFont systemFontOfSize:15];
    self.labelTitle.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:self.labelTitle];
    [_labelTitle release];
    

    
    
    
    // 进度条
    [self.playerView.slider addTarget:self action:@selector(changeTimerValue:) forControlEvents:UIControlEventValueChanged];
    _timer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(changeTimer) userInfo:nil repeats:YES];

    NSTimer *currentTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(changeCurrentTime) userInfo:nil repeats:YES];
    
    // 专辑的图片
    self.playImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width,self.view.bounds.size.width)];
    // 专辑详情播放视图赋值图片
   
    // 将专辑详情播放视图加载到视图上
    //[self.view addSubview:self.playImageView];
    self.tableView.tableHeaderView = self.playImageView;
    
    [self.playerView.audioButton addTarget:self action:@selector(playAudio:) forControlEvents:UIControlEventTouchUpInside];
    
    
    // 创建播放音频的ID视图并设置大小
    self.labelID = [[UILabel alloc]initWithFrame:CGRectMake(20, self.view.bounds.size.width + 64, self.view.bounds.size.width / 4, self.view.bounds.size.width / 2 / 3)];
    // 设置背景颜色
    self.labelID.backgroundColor = [UIColor whiteColor];
    // 赋值
    // 将ID视图加载到视图上
    //[self.view addSubview:self.labelID];
    // 内存管理
    [_labelID release];
    // tableView的偏移量为0
    self.tableView.contentInset = UIEdgeInsetsZero;
    
    // 内存管理
    [_playImageView release];
    
    
}

#pragma mark 播放模式
- (void)playModelClicked:(UIButton *)button
{
    self.playModel = self.playModel % 2 + 1;
    
    if (self.playModel % 2 == 0) {
        
        NSString *circlePath = [[NSBundle mainBundle] pathForResource:@"ttpodicon-1" ofType:@"png"];
        [self.playerView.playModelButton setImage:[UIImage imageWithContentsOfFile:circlePath] forState:UIControlStateNormal];
        _audioPlayer.playmodel = @"One";
    } else {
        
        
        NSString *circlePath = [[NSBundle mainBundle] pathForResource:@"ttpodicon-2" ofType:@"png"];
        [self.playerView.playModelButton setImage:[UIImage imageWithContentsOfFile:circlePath] forState:UIControlStateNormal];
        
        _audioPlayer.playmodel = @"More";

    }
    
}



#pragma mark 点击下一首按钮的方法
- (void)PlayNextSound:(UIButton *)button
{
    
    // 如果index小于列表数组的个数
    if (self.listArr.count != 0) {
        if (_index + 1 < self.listArr.count) {
            _index++;
            // 播放停止
            [_audioPlayer stop];
            self.trackId = [[self.listArr objectAtIndex:_index] trackId];
            if ([[self.listArr objectAtIndex:_index] trackId] == nil) {
                self.trackId = [NSNumber numberWithFloat:[[[self.listArr objectAtIndex:_index] id] floatValue]];
            }
            
            NSLog(@"%@", self.trackId);
            // 解析相关专辑数据
            [self getInfor];
            
            _audioPlayer.url = [NSURL URLWithString:[[self.listArr objectAtIndex:_index] playUrl64]];
            [_audioPlayer play];
            
        }

    }
    
}




#pragma mark 点击上一首按钮的方法
- (void)PlayUpSound:(UIButton *)button
{
    if (self.listArr.count != 0) {
        if (_index - 1 >= 0) {
            _index--;
            [_audioPlayer stop];
            
            self.trackId = [[self.listArr objectAtIndex:_index] trackId];
            if ([[self.listArr objectAtIndex:_index] trackId] == nil) {
                self.trackId = [NSNumber numberWithFloat:[[[self.listArr objectAtIndex:_index] id] floatValue]];
            }
            
            [self getInfor];
            _audioPlayer.url = [NSURL URLWithString:[[self.listArr objectAtIndex:_index] playUrl64]];
            [_audioPlayer play];
            
        }
    }
    
  
    
}

#pragma mark 点击返回按钮
- (void)buttonClicked:(UIButton *)button
{
    // 返回到上一页
    //[self.view removeFromSuperview];
    
    CATransition *transition = [CATransition animation];
    transition.duration = 0.3f;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = @"push";
    transition.subtype = kCATransitionFromBottom;
    transition.delegate = self;
    [self.navigationController.view.layer addAnimation:transition forKey:nil];

    [self.navigationController popViewControllerAnimated:NO];
    
}

#pragma mark 改变进度时间
- (void)changeCurrentTime
{

    
    
    
    NSDate *currentTimeDate = [NSDate dateWithTimeIntervalSince1970:CMTimeGetSeconds(_audioPlayer.myPlayer.currentItem.currentTime)];
    [currentTimeDate dateByAddingTimeInterval:CMTimeGetSeconds(_audioPlayer.myPlayer.currentItem.duration)];
    NSDateFormatter *currentFormat=[[NSDateFormatter alloc]init];
    [currentFormat setDateFormat:@"mm:ss"];
    NSString *currentStr=[currentFormat stringFromDate:currentTimeDate];
    
    self.playerView.currentTime.text = currentStr;
    
    NSDate *totalTimeDate = [NSDate dateWithTimeIntervalSince1970:CMTimeGetSeconds(_audioPlayer.myPlayer.currentItem.duration)];
    [totalTimeDate dateByAddingTimeInterval:CMTimeGetSeconds(_audioPlayer.myPlayer.currentItem.duration)];
    NSDateFormatter *totalTimeFormat = [[NSDateFormatter alloc]init];
    [totalTimeFormat setDateFormat:@"mm:ss"];
    NSString *totalTimeStr =[totalTimeFormat stringFromDate:totalTimeDate];
    self.playerView.totalTime.text = totalTimeStr;
    
    
}

#pragma mark 进度条
- (void)changeTimer
{
    //    self.player.currentItem.duration
    float value = CMTimeGetSeconds(_audioPlayer.myPlayer.currentItem.currentTime) / CMTimeGetSeconds(_audioPlayer.myPlayer.currentItem.duration);
    self.playerView.slider.value = value;
    
    if (_audioPlayer.isPlay == YES) {
       
        self.playerView.audioButton.image = [UIImage imageNamed:playImage];
        [self.playerView.audioButton setColourR:0.0 G:0.0 B:0.0 A:0.0];
       
        
    } else {
         [self.playerView.audioButton setColourR:0.1 G:1.0 B:0.1 A:1.0];
         self.playerView.audioButton.image = [UIImage imageNamed:stopImage];
    }
    
    if (CMTimeGetSeconds(_audioPlayer.myPlayer.currentItem.currentTime) > 0.1) {
        [self.self.playerView.audioButton stopSpin];
    }
    

    
    
    [self.self.playerView.audioButton setProgress:value];
}

#pragma mark 改变进度条
- (void)changeTimerValue:(id)sender
{
    UISlider *slider = (UISlider *)sender;
    float value = slider.value;
    int32_t timer = _audioPlayer.myPlayer.currentItem.asset.duration.timescale;
    Float64 timeValue = CMTimeGetSeconds(_audioPlayer.myPlayer.currentItem.duration) * value;
    [_audioPlayer.myPlayer seekToTime:CMTimeMakeWithSeconds(timeValue, timer) toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
}




#pragma mark 分享按钮
- (void)ShareClicked:(UIButton *)share
{
//    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
//    
//    [window addSubview:self.view];
    
    AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
    
    WBAuthorizeRequest *authRequest = [WBAuthorizeRequest request];
    authRequest.redirectURI = kRedirectURI;
    authRequest.scope = @"all";
    
    WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest requestWithMessage:[self messageToShare] authInfo:authRequest access_token:myDelegate.wbtoken];
    request.userInfo = @{@"ShareMessageFrom": @"MainPlayerViewController",
                         @"Other_Info_1": [NSNumber numberWithInt:123],
                         @"Other_Info_2": @[@"obj1", @"obj2"],
                         @"Other_Info_3": @{@"key1": @"obj1", @"key2": @"obj2"}};
    //    request.shouldOpenWeiboAppInstallPageIfNotInstalled = NO;
    [WeiboSDK sendRequest:request];
    
}

// 分享图片
- (WBMessageObject *)messageToShare
{
    WBMessageObject *message = [WBMessageObject message];
    // 分享的内容 为专辑标题加上专辑音频
    NSString *str = [self.albumDatail.title stringByAppendingString:self.albumDatail.playUrl64];
    message.text = str;
    WBImageObject *image = [WBImageObject object];
    // 选择分享图片
    NSString *path = self.albumDatail.coverLarge;
    NSURL *url = [NSURL URLWithString:path];
    image.imageData = [NSData dataWithContentsOfURL:url];
    message.imageObject = image;
    return message;
}


#pragma mark 收藏按钮
- (void)CollectClicked:(UIButton *)collect
{
    
    // 将数据库中的数据读取出来
    DataBaseHandler *handler = [DataBaseHandler shareInstance];
    
    BOOL result = [handler insertCollect:self.albumDatail];
    if (result) {
        // 当增加成功 弹出收藏成功
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"收藏成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
//        // 收藏成功后将空心图片变为实心的
//        NSString *path1 = [[NSBundle mainBundle] pathForResource:@"collected" ofType:@"jpg"];
//        UIImage *image = [UIImage imageWithContentsOfFile:path1];
//        image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//        [self.playerView.shareButton setImage:image forState:UIControlStateNormal];
        
    } else {
        // 就弹出已收藏的框
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"该内容已收藏" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }

    
    
    

    
    
}




- (void)showDetailInformation
{

         [self getInfor];
        _audioPlayer =  [AudioPlayer shareInstance];
    


    
    if (CMTimeGetSeconds(_audioPlayer.myPlayer.currentItem.currentTime) == 0.0) {
         [self.playerView.audioButton startSpin];
    }

}



- (void)playAudio:(AudioButton *)button
{
     _audioPlayer =  [AudioPlayer shareInstance];
    
    // 如果播放的url与专辑的相等
    if ([[_audioPlayer.url description] isEqualToString: self.albumDatail.playUrl64]) {
            // 播放专辑
            [_audioPlayer play];
        
       
        
    } else {
        // 如果不等 播放停止
        [_audioPlayer stop];
        
        _audioPlayer.button = button;
        // 将专辑详情的url赋值
        _audioPlayer.url = [NSURL URLWithString:_albumDatail.playUrl64];
        // 播放
        [_audioPlayer play];
    }

}


#pragma mark dealloc内存管理
-(void)dealloc
{
    [_albumDatail release];
//    [_streamer release];
    [_trackId release];
    [_playerView release];
    [_listArr release];
    [_navi release];
    [_roundView release];
    [_playTableView release];
    [_soundsArr release];
    [_labelID release];
    [_playImageView release];
    [_labelTitle release];
    [_imageArr release];
    [_tableView release];
    [_host release];
    [_headerView release];
    [_hostAttention release];
    
    [super dealloc];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
